package leetcode.array;

import org.junit.Test;

/**
 * @author mazouri
 * @create 2021-05-02 19:28
 * <p>
 * https://leetcode-cn.com/problems/container-with-most-water/
 */
public class MaxArea_force {
    public int maxArea(int[] height) {
        int maxArea = 0;
        for (int i = 0; i < height.length; i++) {
            for (int j = height.length - 1; j > i; j--) {
                if (height[j] >= height[height.length - 1]) {
                    maxArea = Math.max(maxArea, (j - i) * Math.min(height[i], height[j]));
                }
            }
        }
        return maxArea;
    }

    @Test
    public void test() {
        int[] height = {1, 8, 6, 2, 5, 4, 8, 3, 7};
        System.out.println(maxArea(height));
    }
}
